// Problem 9: Special Pythagorean triplet
// A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,a^2 + b^2 = c^2
// For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.
// There exists exactly one Pythagorean triplet for which a + b + c = 1000.
// Find the product abc.

package main

import (
	"fmt"
)

func p009() int {
	ans := 0
	for c := 410; c < 500; c++ {
		for a := 1; a <= (1000-c)/2; a++ {
			if b := 1000 - a - c; b*b+a*a == c*c {
				ans = a * b * c
				fmt.Println("Problem 009:", ans)
				return ans
			}
		}
	}
	return -1
}
